import { ContainerModule } from '@theia/core/shared/inversify';
import { AppleWidget } from './apple-widget';
import { AppleWidgetViewContribution } from './apple-widget-view-contribution';
import { bindViewContribution, FrontendApplicationContribution, WidgetFactory } from '@theia/core/lib/browser';
import { MenuContribution } from '@theia/core/lib/common/menu';
import { AppleWidgetMenuContribution } from './apple-widget-menu-contribution';

export default new ContainerModule(bind => {
    bindViewContribution(bind, AppleWidgetViewContribution);
    bind(FrontendApplicationContribution).toService(AppleWidgetViewContribution);
    bind(AppleWidget).toSelf();
    bind(WidgetFactory).toDynamicValue(ctx => ({
        id: AppleWidget.ID,
        createWidget: () => ctx.container.get<AppleWidget>(AppleWidget)
    })).inSingletonScope();
    
    // Bind the menu contribution
    bind(MenuContribution).to(AppleWidgetMenuContribution).inSingletonScope();
});
